1. Technical Field
The present invention relates generally to an improved data processing system and in particular to a method and apparatus for managing the use of memory in a data processing system. Still more particularly, the present invention relates to a method and apparatus for managing objects in an object-oriented environment.
2. Description of Related Art
The development of application and system software for data processing systems has traditionally been a time consuming task. The field of software engineering has attempted to overcome the limitations of traditional techniques by proposing new, more efficient software development models. Object oriented programming has emerged as a promising technology allowing for rapid development, implementation and customization of objects. Each new object has certain data attributes and processes or methods that operate on that data. Data is said to be xe2x80x9cencapsulatedxe2x80x9d by an object and can only be modified by the object methods, which are invoked by sending a message to an object identifying the method and supplying any needed arguments.
Object oriented systems have two important properties in addition to encapsulation. xe2x80x9cInheritancexe2x80x9d is the ability to derive a new object from an existing object and inherit all properties, including methods and data structures, from the existing object. The new object may have certain unique features which are supplied as overrides or modifications to the existing class. For example, a new subclass needs to specify only the functions and data that distinguish that class from the existing more general class.
The ability to override an existing method description enables polymorphism, the ability to have a single message to an object be processed in different ways depending on the object itself.
Inheritance and polymorphism create a powerful structure for implementing new software systems. The software developer does not have to develop each piece of a system, he or she need only specify the unique features of the system.
The power of object oriented systems is realized through the development of system xe2x80x9cframeworksxe2x80x9d. A framework is a collection of base classes that can be used by a system implementor to create a final systems product. The framework is defined and developed to work together as a system. Conceptually, the framework is much like a set of standard hardware components used by computer hardware builders. Each of the components has certain defined functions and interfaces and the engineer assembles these components according to a particular design to create a unique hardware system.
In many object-oriented environments, management of the object space is an important area. Java virtual machines are an example of object-oriented systems in object-oriented environments in which object space management is important. The efficiency of object space management affects the overall performance of a Java virtual machine, which in turn affects the overall system performance.
In object-oriented systems, such as Java virtual machines, objects are typically maintained in a memory area called the object xe2x80x9cheapxe2x80x9d. When an object is allocated, a piece of the heap is reserved for the object by the object management system. When an object is freed, the object memory is returned to the object heap for future use. In object-oriented environments, objects are allocated extremely frequently. As a result, an important objective of an object management system is to allow for efficiently performing object allocation. Thus, it would be desirable to have an improved method and apparatus for managing objects through the management of the object space.
The present invention provides a method and data processing system for managing the allocation of memory in an object oriented system executing on the data processing system. A plurality of memory block categories is present in which each memory block category, within the plurality of memory block categories, may contain memory blocks having a memory block size associated with the memory block category. A request is received to allocate memory to an object. This request includes an object size. Whether a memory block category, having an object size corresponding to the object size of the object, contains an available memory block is determined. The available memory block is allocated to the object in response to a determination that the memory block category associated with a size corresponding to the object size of the object contains an available memory block. An available memory block from a memory block category associated with a memory block size larger than the object size is located in response to a determination that an available memory block is absent in the memory block category associated with the size corresponding to the object size. The available memory block, located by the locating step, is partitioned into a number of partitioned memory blocks, each partitioned memory block within the number of partitioned memory blocks having a size corresponding to the object size. A partitioned memory block from the number of partitioned memory blocks is allocated to the object.
This technique is run time adaptive. It will use historical information to determine how many memory blocks of a certain size to make available when larger memory blocks are partitioned.